package org.example.controller;

import jakarta.annotation.Resource;
import org.example.User.BasicThym;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Arrays;
import java.util.Date;

@Resource
@Controller
public class UrlController {
    public Arrays Array;

    @GetMapping("/index")//页面的url地址
    public String getindex(Model model)//对应函数
    {
        model.addAttribute("name","test");
        model.addAttribute("title","thymeleaf的渲染");
        model.addAttribute("keywords","传递的keywords");
        return "/index";//与templates中index.html对应
    }

    @GetMapping("/Basic")//页面的url地址
    public String Basic(Model model)//对应函数
    {
        BasicThym user = new BasicThym();
        user.setUsername("李华");
        user.setAge(22);
        user.setGender(1);
        user.setIsVip(true);
        user.setCreateTime(new Date());
        user.setTags(Array.asList("PHP","Thymeleaf","Node"));
        model.addAttribute("user0",user);
        return "/Basic";//与templates中Basic.html对应
    }

    @GetMapping("/FiveChess")
    public String FiveChess(Model model){
        model.addAttribute("title","五子棋");
        return "/FiveChess";
    }
}